﻿using System;
using JStore.Core.Entities;
using JStore.Core.Enums;
using JStore.Data.Daos;

namespace JStore.Tasks
{
    public class CompanyMoneyLogTask
    {
        private readonly CompanyMoneyLogDao _companyMoneyLogDao = new CompanyMoneyLogDao();

        public void CreateRegLog(int userId, string userName, decimal realMoney, int operUserId, string operUserName)
        {
            var info = new CompanyMoneyLog
                           {
                               CreateDate = DateTime.Now,
                               MoneyType = CompanyMoneyType.Reg,
                               OperUserId = operUserId,
                               OperUserName = operUserName,
                               RealMoney = realMoney,
                               UserId = userId,
                               UserName = userName,
                           };
            _companyMoneyLogDao.Add(info);
        }

        public void CreateUpgradeLog(int userId, string userName, decimal realMoney, int operUserId, string operUserName)
        {
            var info = new CompanyMoneyLog
            {
                CreateDate = DateTime.Now,
                MoneyType = CompanyMoneyType.Upgrade,
                OperUserId = operUserId,
                OperUserName = operUserName,
                UserId = userId,
                RealMoney = realMoney,
                UserName = userName,
            };
            _companyMoneyLogDao.Add(info);
        }


        public decimal GetSum(DateTime startDate, DateTime endDate)
        {
            return _companyMoneyLogDao.GetSum(startDate, endDate);
        }
    }
}